<?php
use App\Common\model\Category;
use app\admin\service\CategoryService;
use app\admin\service\UriService;
?>
<div class="king-layout1-sidebar" style=" height: 100%">
    <div class="" style="height: 100%; position: relative;">
        <div class="m0 p0">
            <nav style="height:100%;">
                <div class="king-vertical-nav4 auto-height">
                    <div class="sidebar-inner">
                        <div class="list-group  side-nav">
                            <?php if(!empty($menus)):?>
                                <div class="list-group ">
                                    <?php foreach($menus as $item):?>
                                    <?php $children = Category::where(['parent_id'=>$item['id']])->where('type','<>',Category::URL)->order(['sort'=>'asc','id'=>'asc'])->select();?>
                                        <?php if(count($children)):?>
                                            <span class="list-group-item">{$item.title}</span>
                                            <?php foreach($children as $child):?>
                                            <a class="list-group-items {$category_id==$child['id']?'actives':''}" href="<?php echo UriService::getCategoryUri($child['id']);?>">{$child.title}</a>
                                                    <?php $child_son = Category::where(['parent_id'=>$child['id']])->where('type','<>',Category::URL)->order(['sort'=>'asc','id'=>'asc'])->select();?>
                                                        <?php if(count($child_son)):?>
                                                            <?php foreach($child_son as $v):?>
                                                                 <a class="list-group-items {$category_id==$v['id']?'actives':''}" href="<?php echo UriService::getCategoryUri($v['id']);?>">={$v.title}</a>
                                                            <?php endforeach;?>
                                                        <?php endif;?>
                                            <?php endforeach;?>
                                        <?php else:?>
                                        <a class="{$category_id==$item['id']?'actives':''} list-group-item" href="<?php echo UriService::getCategoryUri($item['id']);?>">{$item.title}</a>
                                        <?php endif;?>
                                    <?php endforeach;?>
                                </div>
                            <?php endif;?>
                        </div>
                    </div>
                </div>
            </nav>
        </div>
    </div>
</div>
